const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost', {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  dbName: 'test',
  user: 'admin',
  pass: '123456',
});

const db = mongoose.connection;
db.on('open', () => {
  console.log('db open');
});

db.on('error', () => {
  console.log('error');
});